package com.xxxx.seckill.controller;

import com.xxxx.seckill.service.IUserService;
import com.xxxx.seckill.vo.LoginVo;
import com.xxxx.seckill.vo.RespBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.ParameterResolutionDelegate;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 * 登录接口 前端控制器
 * </p>
 *
 * @author heyanfeng
 * @since 2022-08-01
 */
@Controller
@RequestMapping("/login")
@Slf4j
public class LoginController {
    @Autowired
    private IUserService userService;

    /**
     * @Author heyanfeng
     * @Description // 登录跳转
     * @Date 17:20 2022/7/29
     * @Param []
     * @return java.lang.String
     **/
    @RequestMapping("/toLogin")
    public String toLogin(){
        return "login";
    }

   /**
    * @Author heyanfeng
    * @Description // 登录功能
    * @Date 17:20 2022/7/29
    * @Param [loginVo]
    * @return com.xxxx.seckill.vo.RespBean
    **/
    @RequestMapping("doLogin")
    @ResponseBody
    public RespBean doLogin(@Validated LoginVo loginVo, HttpServletRequest request, HttpServletResponse response){
        log.info("{}",loginVo);
        return userService.doLogin(loginVo, request,response);
    }
}
